﻿using CQIE.TES.IDAL;
using CQIE.TES.IService;
using CQIE.TES.Model;
using CQIE.TES.WEB.USER.Models;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;

namespace CQIE.TES.Service
{
    public class Class_Service: IClass_Service
    {
        private readonly IClass_DAL _dal;
        public Class_Service(IClass_DAL dal)
        {
            this._dal = dal;
        }
        /// <summary>
        /// 分页、查询
        /// </summary>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <param name="search"></param>
        /// <param name="count"></param>
        /// <returns></returns>
       public List<Class_> GetClass_Page(int page, int limit, string search, out int count, ENUM_Graduate root)
        {
            //page=0表示第一页，传入的参数为1页开始是第一页，page-1表示传入第一页参数为1是，内部计算0为第一页
            return _dal.GetClass_Page(page-1, limit, search, out count,root);
        }
        /// <summary>
        /// 逻辑删除班级（毕业班级）
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
       public bool DeleteClass_(int id)
        {
            return _dal.DeleteClass_(id);
        }

        public void InsertClass_([FromBody] JObject data) {

            string classCode = data["classCode"].ToString();
            int grade = Convert.ToInt32(data["grade"]);
            string major = data["major"].ToString();
            _dal.InsertClass_(classCode, grade, major);
        }

        public List<Class_> GetClassIDToStudent()
        {
            return _dal.GetClassIDToStudent();
        }
    }
}
